// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.TransformManagement
{
	public sealed class TransformPreviewTransformRequestParameters : RequestParameters<TransformPreviewTransformRequestParameters>
	{
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }
	}

	public sealed partial class TransformPreviewTransformRequest : PlainRequestBase<TransformPreviewTransformRequestParameters>
	{
		public TransformPreviewTransformRequest()
		{
		}

		public TransformPreviewTransformRequest(Elastic.Clients.Elasticsearch.Id? transform_id) : base(r => r.Optional("transform_id", transform_id))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.TransformManagementPreviewTransform;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

		[JsonInclude]
		[JsonPropertyName("dest")]
		public Elastic.Clients.Elasticsearch.TransformManagement.Destination? Dest { get; set; }

		[JsonInclude]
		[JsonPropertyName("description")]
		public string? Description { get; set; }

		[JsonInclude]
		[JsonPropertyName("frequency")]
		public Elastic.Clients.Elasticsearch.Duration? Frequency { get; set; }

		[JsonInclude]
		[JsonPropertyName("pivot")]
		public Elastic.Clients.Elasticsearch.TransformManagement.Pivot? Pivot { get; set; }

		[JsonInclude]
		[JsonPropertyName("source")]
		public Elastic.Clients.Elasticsearch.TransformManagement.Source? Source { get; set; }

		[JsonInclude]
		[JsonPropertyName("settings")]
		public Elastic.Clients.Elasticsearch.TransformManagement.Settings? Settings { get; set; }

		[JsonInclude]
		[JsonPropertyName("sync")]
		public Elastic.Clients.Elasticsearch.TransformManagement.SyncContainer? Sync { get; set; }

		[JsonInclude]
		[JsonPropertyName("retention_policy")]
		public Elastic.Clients.Elasticsearch.TransformManagement.RetentionPolicyContainer? RetentionPolicy { get; set; }

		[JsonInclude]
		[JsonPropertyName("latest")]
		public Elastic.Clients.Elasticsearch.TransformManagement.Latest? Latest { get; set; }
	}

	public sealed partial class TransformPreviewTransformRequestDescriptor<TDocument> : RequestDescriptorBase<TransformPreviewTransformRequestDescriptor<TDocument>, TransformPreviewTransformRequestParameters>
	{
		internal TransformPreviewTransformRequestDescriptor(Action<TransformPreviewTransformRequestDescriptor<TDocument>> configure) => configure.Invoke(this);
		public TransformPreviewTransformRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.TransformManagementPreviewTransform;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public TransformPreviewTransformRequestDescriptor<TDocument> Timeout(Elastic.Clients.Elasticsearch.Duration? timeout) => Qs("timeout", timeout);
		public TransformPreviewTransformRequestDescriptor<TDocument> TransformId(Elastic.Clients.Elasticsearch.Id? transform_id)
		{
			RouteValues.Optional("transform_id", transform_id);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.TransformManagement.Latest? LatestValue { get; set; }

		private LatestDescriptor<TDocument> LatestDescriptor { get; set; }

		private Action<LatestDescriptor<TDocument>> LatestDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.RetentionPolicyContainer? RetentionPolicyValue { get; set; }

		private RetentionPolicyContainerDescriptor<TDocument> RetentionPolicyDescriptor { get; set; }

		private Action<RetentionPolicyContainerDescriptor<TDocument>> RetentionPolicyDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.Source? SourceValue { get; set; }

		private SourceDescriptor<TDocument> SourceDescriptor { get; set; }

		private Action<SourceDescriptor<TDocument>> SourceDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.SyncContainer? SyncValue { get; set; }

		private SyncContainerDescriptor<TDocument> SyncDescriptor { get; set; }

		private Action<SyncContainerDescriptor<TDocument>> SyncDescriptorAction { get; set; }

		private string? DescriptionValue { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.Destination? DestValue { get; set; }

		private DestinationDescriptor DestDescriptor { get; set; }

		private Action<DestinationDescriptor> DestDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? FrequencyValue { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.Pivot? PivotValue { get; set; }

		private PivotDescriptor PivotDescriptor { get; set; }

		private Action<PivotDescriptor> PivotDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.Settings? SettingsValue { get; set; }

		private SettingsDescriptor SettingsDescriptor { get; set; }

		private Action<SettingsDescriptor> SettingsDescriptorAction { get; set; }

		public TransformPreviewTransformRequestDescriptor<TDocument> Latest(Elastic.Clients.Elasticsearch.TransformManagement.Latest? latest)
		{
			LatestDescriptor = null;
			LatestDescriptorAction = null;
			LatestValue = latest;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Latest(LatestDescriptor<TDocument> descriptor)
		{
			LatestValue = null;
			LatestDescriptorAction = null;
			LatestDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Latest(Action<LatestDescriptor<TDocument>> configure)
		{
			LatestValue = null;
			LatestDescriptor = null;
			LatestDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> RetentionPolicy(Elastic.Clients.Elasticsearch.TransformManagement.RetentionPolicyContainer? retentionPolicy)
		{
			RetentionPolicyDescriptor = null;
			RetentionPolicyDescriptorAction = null;
			RetentionPolicyValue = retentionPolicy;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> RetentionPolicy(RetentionPolicyContainerDescriptor<TDocument> descriptor)
		{
			RetentionPolicyValue = null;
			RetentionPolicyDescriptorAction = null;
			RetentionPolicyDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> RetentionPolicy(Action<RetentionPolicyContainerDescriptor<TDocument>> configure)
		{
			RetentionPolicyValue = null;
			RetentionPolicyDescriptor = null;
			RetentionPolicyDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Source(Elastic.Clients.Elasticsearch.TransformManagement.Source? source)
		{
			SourceDescriptor = null;
			SourceDescriptorAction = null;
			SourceValue = source;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Source(SourceDescriptor<TDocument> descriptor)
		{
			SourceValue = null;
			SourceDescriptorAction = null;
			SourceDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Source(Action<SourceDescriptor<TDocument>> configure)
		{
			SourceValue = null;
			SourceDescriptor = null;
			SourceDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Sync(Elastic.Clients.Elasticsearch.TransformManagement.SyncContainer? sync)
		{
			SyncDescriptor = null;
			SyncDescriptorAction = null;
			SyncValue = sync;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Sync(SyncContainerDescriptor<TDocument> descriptor)
		{
			SyncValue = null;
			SyncDescriptorAction = null;
			SyncDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Sync(Action<SyncContainerDescriptor<TDocument>> configure)
		{
			SyncValue = null;
			SyncDescriptor = null;
			SyncDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Description(string? description)
		{
			DescriptionValue = description;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Dest(Elastic.Clients.Elasticsearch.TransformManagement.Destination? dest)
		{
			DestDescriptor = null;
			DestDescriptorAction = null;
			DestValue = dest;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Dest(DestinationDescriptor descriptor)
		{
			DestValue = null;
			DestDescriptorAction = null;
			DestDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Dest(Action<DestinationDescriptor> configure)
		{
			DestValue = null;
			DestDescriptor = null;
			DestDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Frequency(Elastic.Clients.Elasticsearch.Duration? frequency)
		{
			FrequencyValue = frequency;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Pivot(Elastic.Clients.Elasticsearch.TransformManagement.Pivot? pivot)
		{
			PivotDescriptor = null;
			PivotDescriptorAction = null;
			PivotValue = pivot;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Pivot(PivotDescriptor descriptor)
		{
			PivotValue = null;
			PivotDescriptorAction = null;
			PivotDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Pivot(Action<PivotDescriptor> configure)
		{
			PivotValue = null;
			PivotDescriptor = null;
			PivotDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Settings(Elastic.Clients.Elasticsearch.TransformManagement.Settings? settings)
		{
			SettingsDescriptor = null;
			SettingsDescriptorAction = null;
			SettingsValue = settings;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Settings(SettingsDescriptor descriptor)
		{
			SettingsValue = null;
			SettingsDescriptorAction = null;
			SettingsDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor<TDocument> Settings(Action<SettingsDescriptor> configure)
		{
			SettingsValue = null;
			SettingsDescriptor = null;
			SettingsDescriptorAction = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (LatestDescriptor is not null)
			{
				writer.WritePropertyName("latest");
				JsonSerializer.Serialize(writer, LatestDescriptor, options);
			}
			else if (LatestDescriptorAction is not null)
			{
				writer.WritePropertyName("latest");
				JsonSerializer.Serialize(writer, new LatestDescriptor<TDocument>(LatestDescriptorAction), options);
			}
			else if (LatestValue is not null)
			{
				writer.WritePropertyName("latest");
				JsonSerializer.Serialize(writer, LatestValue, options);
			}

			if (RetentionPolicyDescriptor is not null)
			{
				writer.WritePropertyName("retention_policy");
				JsonSerializer.Serialize(writer, RetentionPolicyDescriptor, options);
			}
			else if (RetentionPolicyDescriptorAction is not null)
			{
				writer.WritePropertyName("retention_policy");
				JsonSerializer.Serialize(writer, new RetentionPolicyContainerDescriptor<TDocument>(RetentionPolicyDescriptorAction), options);
			}
			else if (RetentionPolicyValue is not null)
			{
				writer.WritePropertyName("retention_policy");
				JsonSerializer.Serialize(writer, RetentionPolicyValue, options);
			}

			if (SourceDescriptor is not null)
			{
				writer.WritePropertyName("source");
				JsonSerializer.Serialize(writer, SourceDescriptor, options);
			}
			else if (SourceDescriptorAction is not null)
			{
				writer.WritePropertyName("source");
				JsonSerializer.Serialize(writer, new SourceDescriptor<TDocument>(SourceDescriptorAction), options);
			}
			else if (SourceValue is not null)
			{
				writer.WritePropertyName("source");
				JsonSerializer.Serialize(writer, SourceValue, options);
			}

			if (SyncDescriptor is not null)
			{
				writer.WritePropertyName("sync");
				JsonSerializer.Serialize(writer, SyncDescriptor, options);
			}
			else if (SyncDescriptorAction is not null)
			{
				writer.WritePropertyName("sync");
				JsonSerializer.Serialize(writer, new SyncContainerDescriptor<TDocument>(SyncDescriptorAction), options);
			}
			else if (SyncValue is not null)
			{
				writer.WritePropertyName("sync");
				JsonSerializer.Serialize(writer, SyncValue, options);
			}

			if (!string.IsNullOrEmpty(DescriptionValue))
			{
				writer.WritePropertyName("description");
				writer.WriteStringValue(DescriptionValue);
			}

			if (DestDescriptor is not null)
			{
				writer.WritePropertyName("dest");
				JsonSerializer.Serialize(writer, DestDescriptor, options);
			}
			else if (DestDescriptorAction is not null)
			{
				writer.WritePropertyName("dest");
				JsonSerializer.Serialize(writer, new DestinationDescriptor(DestDescriptorAction), options);
			}
			else if (DestValue is not null)
			{
				writer.WritePropertyName("dest");
				JsonSerializer.Serialize(writer, DestValue, options);
			}

			if (FrequencyValue is not null)
			{
				writer.WritePropertyName("frequency");
				JsonSerializer.Serialize(writer, FrequencyValue, options);
			}

			if (PivotDescriptor is not null)
			{
				writer.WritePropertyName("pivot");
				JsonSerializer.Serialize(writer, PivotDescriptor, options);
			}
			else if (PivotDescriptorAction is not null)
			{
				writer.WritePropertyName("pivot");
				JsonSerializer.Serialize(writer, new PivotDescriptor(PivotDescriptorAction), options);
			}
			else if (PivotValue is not null)
			{
				writer.WritePropertyName("pivot");
				JsonSerializer.Serialize(writer, PivotValue, options);
			}

			if (SettingsDescriptor is not null)
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, SettingsDescriptor, options);
			}
			else if (SettingsDescriptorAction is not null)
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, new SettingsDescriptor(SettingsDescriptorAction), options);
			}
			else if (SettingsValue is not null)
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, SettingsValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class TransformPreviewTransformRequestDescriptor : RequestDescriptorBase<TransformPreviewTransformRequestDescriptor, TransformPreviewTransformRequestParameters>
	{
		internal TransformPreviewTransformRequestDescriptor(Action<TransformPreviewTransformRequestDescriptor> configure) => configure.Invoke(this);
		public TransformPreviewTransformRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.TransformManagementPreviewTransform;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public TransformPreviewTransformRequestDescriptor Timeout(Elastic.Clients.Elasticsearch.Duration? timeout) => Qs("timeout", timeout);
		public TransformPreviewTransformRequestDescriptor TransformId(Elastic.Clients.Elasticsearch.Id? transform_id)
		{
			RouteValues.Optional("transform_id", transform_id);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.TransformManagement.Latest? LatestValue { get; set; }

		private LatestDescriptor LatestDescriptor { get; set; }

		private Action<LatestDescriptor> LatestDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.RetentionPolicyContainer? RetentionPolicyValue { get; set; }

		private RetentionPolicyContainerDescriptor RetentionPolicyDescriptor { get; set; }

		private Action<RetentionPolicyContainerDescriptor> RetentionPolicyDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.Source? SourceValue { get; set; }

		private SourceDescriptor SourceDescriptor { get; set; }

		private Action<SourceDescriptor> SourceDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.SyncContainer? SyncValue { get; set; }

		private SyncContainerDescriptor SyncDescriptor { get; set; }

		private Action<SyncContainerDescriptor> SyncDescriptorAction { get; set; }

		private string? DescriptionValue { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.Destination? DestValue { get; set; }

		private DestinationDescriptor DestDescriptor { get; set; }

		private Action<DestinationDescriptor> DestDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? FrequencyValue { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.Pivot? PivotValue { get; set; }

		private PivotDescriptor PivotDescriptor { get; set; }

		private Action<PivotDescriptor> PivotDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.TransformManagement.Settings? SettingsValue { get; set; }

		private SettingsDescriptor SettingsDescriptor { get; set; }

		private Action<SettingsDescriptor> SettingsDescriptorAction { get; set; }

		public TransformPreviewTransformRequestDescriptor Latest(Elastic.Clients.Elasticsearch.TransformManagement.Latest? latest)
		{
			LatestDescriptor = null;
			LatestDescriptorAction = null;
			LatestValue = latest;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Latest(LatestDescriptor descriptor)
		{
			LatestValue = null;
			LatestDescriptorAction = null;
			LatestDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Latest(Action<LatestDescriptor> configure)
		{
			LatestValue = null;
			LatestDescriptor = null;
			LatestDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor RetentionPolicy(Elastic.Clients.Elasticsearch.TransformManagement.RetentionPolicyContainer? retentionPolicy)
		{
			RetentionPolicyDescriptor = null;
			RetentionPolicyDescriptorAction = null;
			RetentionPolicyValue = retentionPolicy;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor RetentionPolicy(RetentionPolicyContainerDescriptor descriptor)
		{
			RetentionPolicyValue = null;
			RetentionPolicyDescriptorAction = null;
			RetentionPolicyDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor RetentionPolicy(Action<RetentionPolicyContainerDescriptor> configure)
		{
			RetentionPolicyValue = null;
			RetentionPolicyDescriptor = null;
			RetentionPolicyDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Source(Elastic.Clients.Elasticsearch.TransformManagement.Source? source)
		{
			SourceDescriptor = null;
			SourceDescriptorAction = null;
			SourceValue = source;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Source(SourceDescriptor descriptor)
		{
			SourceValue = null;
			SourceDescriptorAction = null;
			SourceDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Source(Action<SourceDescriptor> configure)
		{
			SourceValue = null;
			SourceDescriptor = null;
			SourceDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Sync(Elastic.Clients.Elasticsearch.TransformManagement.SyncContainer? sync)
		{
			SyncDescriptor = null;
			SyncDescriptorAction = null;
			SyncValue = sync;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Sync(SyncContainerDescriptor descriptor)
		{
			SyncValue = null;
			SyncDescriptorAction = null;
			SyncDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Sync(Action<SyncContainerDescriptor> configure)
		{
			SyncValue = null;
			SyncDescriptor = null;
			SyncDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Description(string? description)
		{
			DescriptionValue = description;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Dest(Elastic.Clients.Elasticsearch.TransformManagement.Destination? dest)
		{
			DestDescriptor = null;
			DestDescriptorAction = null;
			DestValue = dest;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Dest(DestinationDescriptor descriptor)
		{
			DestValue = null;
			DestDescriptorAction = null;
			DestDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Dest(Action<DestinationDescriptor> configure)
		{
			DestValue = null;
			DestDescriptor = null;
			DestDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Frequency(Elastic.Clients.Elasticsearch.Duration? frequency)
		{
			FrequencyValue = frequency;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Pivot(Elastic.Clients.Elasticsearch.TransformManagement.Pivot? pivot)
		{
			PivotDescriptor = null;
			PivotDescriptorAction = null;
			PivotValue = pivot;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Pivot(PivotDescriptor descriptor)
		{
			PivotValue = null;
			PivotDescriptorAction = null;
			PivotDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Pivot(Action<PivotDescriptor> configure)
		{
			PivotValue = null;
			PivotDescriptor = null;
			PivotDescriptorAction = configure;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Settings(Elastic.Clients.Elasticsearch.TransformManagement.Settings? settings)
		{
			SettingsDescriptor = null;
			SettingsDescriptorAction = null;
			SettingsValue = settings;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Settings(SettingsDescriptor descriptor)
		{
			SettingsValue = null;
			SettingsDescriptorAction = null;
			SettingsDescriptor = descriptor;
			return Self;
		}

		public TransformPreviewTransformRequestDescriptor Settings(Action<SettingsDescriptor> configure)
		{
			SettingsValue = null;
			SettingsDescriptor = null;
			SettingsDescriptorAction = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (LatestDescriptor is not null)
			{
				writer.WritePropertyName("latest");
				JsonSerializer.Serialize(writer, LatestDescriptor, options);
			}
			else if (LatestDescriptorAction is not null)
			{
				writer.WritePropertyName("latest");
				JsonSerializer.Serialize(writer, new LatestDescriptor(LatestDescriptorAction), options);
			}
			else if (LatestValue is not null)
			{
				writer.WritePropertyName("latest");
				JsonSerializer.Serialize(writer, LatestValue, options);
			}

			if (RetentionPolicyDescriptor is not null)
			{
				writer.WritePropertyName("retention_policy");
				JsonSerializer.Serialize(writer, RetentionPolicyDescriptor, options);
			}
			else if (RetentionPolicyDescriptorAction is not null)
			{
				writer.WritePropertyName("retention_policy");
				JsonSerializer.Serialize(writer, new RetentionPolicyContainerDescriptor(RetentionPolicyDescriptorAction), options);
			}
			else if (RetentionPolicyValue is not null)
			{
				writer.WritePropertyName("retention_policy");
				JsonSerializer.Serialize(writer, RetentionPolicyValue, options);
			}

			if (SourceDescriptor is not null)
			{
				writer.WritePropertyName("source");
				JsonSerializer.Serialize(writer, SourceDescriptor, options);
			}
			else if (SourceDescriptorAction is not null)
			{
				writer.WritePropertyName("source");
				JsonSerializer.Serialize(writer, new SourceDescriptor(SourceDescriptorAction), options);
			}
			else if (SourceValue is not null)
			{
				writer.WritePropertyName("source");
				JsonSerializer.Serialize(writer, SourceValue, options);
			}

			if (SyncDescriptor is not null)
			{
				writer.WritePropertyName("sync");
				JsonSerializer.Serialize(writer, SyncDescriptor, options);
			}
			else if (SyncDescriptorAction is not null)
			{
				writer.WritePropertyName("sync");
				JsonSerializer.Serialize(writer, new SyncContainerDescriptor(SyncDescriptorAction), options);
			}
			else if (SyncValue is not null)
			{
				writer.WritePropertyName("sync");
				JsonSerializer.Serialize(writer, SyncValue, options);
			}

			if (!string.IsNullOrEmpty(DescriptionValue))
			{
				writer.WritePropertyName("description");
				writer.WriteStringValue(DescriptionValue);
			}

			if (DestDescriptor is not null)
			{
				writer.WritePropertyName("dest");
				JsonSerializer.Serialize(writer, DestDescriptor, options);
			}
			else if (DestDescriptorAction is not null)
			{
				writer.WritePropertyName("dest");
				JsonSerializer.Serialize(writer, new DestinationDescriptor(DestDescriptorAction), options);
			}
			else if (DestValue is not null)
			{
				writer.WritePropertyName("dest");
				JsonSerializer.Serialize(writer, DestValue, options);
			}

			if (FrequencyValue is not null)
			{
				writer.WritePropertyName("frequency");
				JsonSerializer.Serialize(writer, FrequencyValue, options);
			}

			if (PivotDescriptor is not null)
			{
				writer.WritePropertyName("pivot");
				JsonSerializer.Serialize(writer, PivotDescriptor, options);
			}
			else if (PivotDescriptorAction is not null)
			{
				writer.WritePropertyName("pivot");
				JsonSerializer.Serialize(writer, new PivotDescriptor(PivotDescriptorAction), options);
			}
			else if (PivotValue is not null)
			{
				writer.WritePropertyName("pivot");
				JsonSerializer.Serialize(writer, PivotValue, options);
			}

			if (SettingsDescriptor is not null)
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, SettingsDescriptor, options);
			}
			else if (SettingsDescriptorAction is not null)
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, new SettingsDescriptor(SettingsDescriptorAction), options);
			}
			else if (SettingsValue is not null)
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, SettingsValue, options);
			}

			writer.WriteEndObject();
		}
	}
}